
Ext.data.DWRProxy = function(dwrCall, pagingAndSort){
  Ext.data.DWRProxy.superclass.constructor.call(this);
  this.dwrCall = dwrCall;
	this.pagingAndSort = (pagingAndSort!=undefined ? pagingAndSort : true);
};

Ext.extend(Ext.data.DWRProxy, Ext.data.DataProxy, {
  load : function(params, reader, callback, scope, arg) {
    if(this.fireEvent("beforeload", this, params) !== false) {
      var delegate = this.loadResponse.createDelegate(this, [reader, callback, scope, arg], 1);
      var callParams = new Array();
	  callParams.push(arg.params);
      callParams.push(delegate);
      this.dwrCall.apply(this, callParams);
    } else {
      callback.call(scope || this, null, arg, false);
    }
  },

  loadResponse : function(dwrResult, reader, callback, scope, arg) {
    var result;
    try {
      result = reader.read(dwrResult);
    } catch(e) {
      this.fireEvent("loadexception", this, null, dwrResult, e);
      callback.call(scope, null, arg, false);
      return;
    }
    callback.call(scope, result, arg, true);
  }
});
Ext.data.DWRJsonReader=function(meta,recordType){   
  Ext.data.DWRJsonReader.superclass.constructor.call(this,meta,recordType);   
};   
  
Ext.extend(Ext.data.DWRJsonReader,Ext.data.JsonReader,{   
  read : function(response){
  	    if(typeof response == 'object')
  	      alert("object");
        var o = eval("("+response+")");
        if(!o) {
            throw {message: "JsonReader.read: Json object not found"};
        }
        if(o.metaData){
            delete this.ef;
            this.meta = o.metaData;
            this.recordType = Ext.data.Record.create(o.metaData.fields);
            this.onMetaChange(this.meta, this.recordType, o);
        }
        return this.readRecords(o);
    }  
});  

